package com.zhang.mapper;

import com.zhang.entity.UserInfo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.transaction.annotation.Transactional;

/**
 * Created with IntelliJ IDEA.
 * User: 张
 * Date: 2024-10-28
 * Time: 15:59
 * Description:
 */
@Transactional(rollbackFor = Exception.class)//事务回滚(所有异常都会回滚)
@Mapper
public interface UserInfoMapper {
    @Select("select * from visions_sort.user_info where phone=#{account} and user_state = #{userState}")
    UserInfo getUserInfoByUserAccount(String account, Integer userState);

    void registerUser(UserInfo user);
    @Select("select email from visions_sort.user_info where phone = #{phone} and user_state = #{userState}")
    String getEmailByPhone(@Param("phone") String phone,@Param("userState")Integer userState);

    @Update("update visions_sort.user_info set password = #{password} where phone = #{phone}")
    void updatePasswordByPhone(@Param("phone") String phone,@Param("password") String password);

}
